#include<iostream>
using namespace std;
int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };

bool check_valid(int data)
{
	int year = data / 10000;
	int month2 = data / 100 % 100;
	int day = data % 100;
	if (month2 == 0 || month2 > 12)return 0;
	if ((day == 0 || day > month[month2]) && month2 != 2)return 0;
	int leap = year % 400 == 0 || year % 4 == 0 && year % 100 ;
	if (month2 == 2) {
		if (day > 28 + leap) {
			return 0;
		}
	}
	return 1;
}
int main()
{
	int data1, data2;
	cin >> data1 >> data2;
	int ans = 0;
	for (int i = 1000; i < 10000; i++) {
		int data = i;
		int x = i;
		for (int j = 0; j < 4; j++) {
			data = data * 10 + x % 10;
			x /= 10;
		}
		if (data1 <= data && data <= data2 && check_valid(data)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}